Skip to content

fix(‎LibCarla): port lane marking, waypoint loop, lane corners, and pugixml null fixes#9652

Merged
Blyron merged 4 commits intocarla-simulator:ue5-devfrom
youtalk:fix/opendrive-lane-waypoint-fixes
Apr 16, 2026
Merged

fix(‎LibCarla): port lane marking, waypoint loop, lane corners, and pugixml null fixes#9652
Blyron merged 4 commits intocarla-simulator:ue5-devfrom
youtalk:fix/opendrive-lane-waypoint-fixes

Conversation

@youtalk
Copy link
Copy Markdown
Contributor

@youtalk youtalk commented Apr 7, 2026

Description

Port of 4 ue4-dev bug fixes:

  1. Lane marking generation
    (86fcfe5e8) — Extract ComputeEdgesForLanemark helper to handle zero-width lanes without divide-by-zero. Add edges.first == edges.second guard in tree generation.

  2. Waypoint next/previous infinite loop
    (e41ffa03c) — Prevent infinite recursion in GetNext/GetPrevious when two roads with opposite directions are connected as each other's successor.

  3. Lane corners crash (4d4dd1d11) — Clamp s parameter in GetCornerPositions to [0, road_length] to prevent crash when requested s exceeds lane distance.

  4. pugixml null pointer dereference
    (4ca87e818 + 6cb77140c) — Add !_root null checks in 6 xml_node insertion methods to prevent crashes on empty nodes. Includes Google Test cases.

Where has this been tested?

  • Platform(s): Ubuntu 24.04
  • Python version(s): N/A (C++ only)
  • Unreal Engine version(s): 5.5

Possible Drawbacks

None. All changes are defensive guards and bug fixes.


This change is Reviewable

…l null fixes

Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
@update-docs
Copy link
Copy Markdown

update-docs bot commented Apr 7, 2026

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update our CHANGELOG.md based on your changes.

@youtalk youtalk closed this Apr 7, 2026
@youtalk youtalk reopened this Apr 7, 2026
@youtalk youtalk changed the title fix(road): port lane marking, waypoint loop, lane corners, and pugixml null fixes fix(‎LibCarla): port lane marking, waypoint loop, lane corners, and pugixml null fixes Apr 7, 2026
@youtalk youtalk marked this pull request as ready for review April 7, 2026 21:26
@youtalk youtalk requested a review from a team as a code owner April 7, 2026 21:26
Copilot AI review requested due to automatic review settings April 7, 2026 21:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Ports several UE4-dev bug fixes into LibCarla, focusing on preventing crashes/infinite loops and improving robustness in lane marking generation and XML node insertion.

Changes:

  • Add _root null-guards to multiple pugixml insertion APIs and introduce GTest coverage.
  • Refactor lane marking generation to use a helper that avoids divide-by-zero on zero-width lanes.
  • Prevent waypoint traversal infinite recursion and harden lane corner computations (clamping s).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
LibCarla/source/third-party/pugixml/pugixml.cpp Adds _root null checks to avoid crashes during insertion operations.
LibCarla/source/test/common/test_pugixml.cpp Introduces GTests intended to validate the pugixml null-guard behavior.
LibCarla/source/carla/road/MeshFactory.h Declares a helper for lane marking edge computation.
LibCarla/source/carla/road/MeshFactory.cpp Uses the helper to generate lane marking geometry and implements robust edge computation.
LibCarla/source/carla/road/Map.cpp Adds loop-breaking logic in waypoint traversal and a guard for degenerate edges in tree placement.
LibCarla/source/carla/road/Lane.cpp Clamps s in GetCornerPositions to avoid out-of-range crashes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread LibCarla/source/carla/road/MeshFactory.cpp Outdated
Comment thread LibCarla/source/carla/road/MeshFactory.cpp Outdated
Comment thread LibCarla/source/carla/road/MeshFactory.cpp
Comment thread LibCarla/source/carla/road/Map.cpp Outdated
Comment thread LibCarla/source/test/common/test_pugixml.cpp
Comment thread LibCarla/source/test/common/test_pugixml.cpp
Comment thread LibCarla/source/carla/road/Map.cpp Outdated
Copy link
Copy Markdown
Contributor

@JesusAnaya JesusAnaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has one potential bug (LibCarla/source/carla/road/Map.cpp:1294-1306). Please review my comments.

Comment thread LibCarla/source/carla/road/Map.cpp Outdated
Comment thread LibCarla/source/carla/road/MeshFactory.cpp Outdated
Comment thread LibCarla/source/carla/road/MeshFactory.cpp
Comment thread LibCarla/source/carla/road/MeshFactory.cpp Outdated
Comment thread LibCarla/source/carla/road/Map.cpp Outdated
Comment thread LibCarla/source/carla/road/Map.cpp
Comment thread LibCarla/source/test/common/test_pugixml.cpp
youtalk and others added 2 commits April 8, 2026 16:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Invert the degenerate-edges guard so that only tree placement is
skipped when edges.first == edges.second, instead of using continue
which skipped the s_current increment and caused an infinite loop.

Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
The refactored ComputeEdgesForLanemark helper always used
road_param.extra_lane_width, but the original code used extra_width=0
for Solid lane markings and end marking vertices. This shifted solid
lane marking geometry away from the lane boundary.

Add an extra_width parameter and forward the original values from each
call site: 0.0f for Solid/end-marking, road_param.extra_lane_width for
Broken/Dashed.

Fixes carla-simulator#9677

Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
@youtalk
Copy link
Copy Markdown
Contributor Author

youtalk commented Apr 15, 2026

@Blyron Please review this.

@Blyron Blyron merged commit 87ce737 into carla-simulator:ue5-dev Apr 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants